package setup

import (
	"context"
	"gitee.com/kmyss/gf-ex/yscmd"
	"gitee.com/kmyss/gf-ex/yslog"
	"gitee.com/kmyss/ys-cli/internal/service"
)

type Builder struct {
	yscmd.CommandBuilderCore
}

func (b *Builder) Init(ctx context.Context) {
	b.CommandBuilderCore.Init(ctx)
	b.C.Use = "setup"
	b.C.Short = "初始化虚拟环境"

	b.C.Run = run
}

func run(c *yscmd.Command) {
	err := service.Python().Setup(c.Context())
	if err != nil {
		yslog.Error(err)
		yscmd.CmdWait(c.Context())
		return
	}
}
func Setup(ctx context.Context) *yscmd.Command {
	c := &Builder{}
	c.Init(ctx)
	return c.Command()
}
